package com.pcbly.web.persistence.timesheet;

import com.pcbly.web.components.utils.random.GUID;
import com.pcbly.web.bean.timesheet.TimesheetLogBean;
import com.pcbly.web.persistence.HibernateBaseDao;

public class TimesheetLogHibernateDao extends
		HibernateBaseDao<TimesheetLogBean> implements TimesheetLogDao {
	/**
	 * 
	 */
	private static final long serialVersionUID = -7222005438328498342L;

	protected Class<TimesheetLogBean> getEntityClass() {
		return TimesheetLogBean.class;
	}

	public TimesheetLogHibernateDao() {
		super();
	}

	@Override
	public void saveTimesheetLogBean(TimesheetLogBean timesheet)
			throws Exception {
		if (logger.isDebugEnabled()) {
			logger.debug(timesheet.getId());
		}
		String id = (new GUID()).toString();
		timesheet.setId(id);
		getHibernateTemplate().save(timesheet);
	}

	@Override
	public void removeTimesheetLogBeanByIds(String ids) throws Exception {
		// TODO Auto-generated method stub
		ids = ids.replaceAll(",", "','");
		String hsql = "delete from t_timesheet_log where ID in( '" + ids + "')";
		getSession().createSQLQuery(hsql).executeUpdate();

	}
}